package com.example.demo01.controller;

import com.example.demo01.eneity.YzfCompetition;
import com.example.demo01.eneity.YzfUser;
import com.example.demo01.service.YzfCompetitionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//处理 HTTP 请求，返回值直接作为 HTTP Response Body 输出
@RestController
@RequestMapping("/user")
public class YzfCompetitionController {

   // 注入YzfCompetitionService
   @Autowired
    private YzfCompetitionService yzfCompetitionService;


   @GetMapping("/get")
    public List<YzfCompetition> getYzfUserService() {

        //调用yzfCompetitionService的getCompetitions方法获取比赛信息
        return yzfCompetitionService.getCompetitions();
    }

    @GetMapping("/")
    public  List<YzfCompetition> getCompetition() {
        //调用yzfCompetitionService的getAllCompetitionsWithCategories方法获取比赛信息
        return  yzfCompetitionService.getAllCompetitionsWithCategories();
    }


    @GetMapping("/{id}")
    public  List<YzfUser>  getById(@PathVariable Integer id){
        //调用yzfCompetitionService的getCompetitionJudges方法根据id获取比赛评委信息
        List<YzfUser> yzfUsers = yzfCompetitionService. getCompetitionJudges(id);
        return  yzfUsers;
    }



}